package liurong.driver.aio;

import java.net.InetSocketAddress;
import java.nio.channels.AsynchronousChannelGroup;
import java.nio.channels.AsynchronousServerSocketChannel;
import java.nio.channels.AsynchronousSocketChannel;
import java.util.concurrent.Executors;

public class Server {

	public static void main(String[] args) {
		try {
			AsynchronousChannelGroup threadGroup = AsynchronousChannelGroup
					.withThreadPool(Executors.newFixedThreadPool(10));
			AsynchronousServerSocketChannel serverSocketChannel = AsynchronousServerSocketChannel.open(threadGroup);
			serverSocketChannel.bind(new InetSocketAddress(8087), 64);

			while (true) {
				AsynchronousSocketChannel socketChannel = serverSocketChannel.accept().get();
				socketChannel.read(null);
			}

		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}
